<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">

    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Neon Admin Panel">
    <meta name="author" content="">

    <title>Green Soil | 材料数据管理</title>


    <link rel="stylesheet" href="static/css/jquery-ui-1.10.3.custom.min.css">
    <link rel="stylesheet" href="static/css/entypo.css">
    <link rel="stylesheet" href="static/css/css.css">
    <link rel="stylesheet" href="static/css/bootstrap.css">
    <link rel="stylesheet" href="static/css/neon-core.css">
    <link rel="stylesheet" href="static/css/neon-theme.css">
    <link rel="stylesheet" href="static/css/neon-forms.css">
    <link rel="stylesheet" href="static/css/custom.css">
    <script src="./gethost.js" type="text/javascript"></script>

    <script src="static/js/jquery-1.11.0.min.js"></script>

</head>

<body class="page-body">

<div class="page-container">
    <!-- add class "sidebar-collapsed" to close sidebar by default, "chat-visible" to make chat appear always -->

    <div class="sidebar-menu">

        <header class="logo-env">

            <!-- logo -->
            <div class="logo">
                <a href="">
                    <img src="static/picture/green.png" width="150" alt="">
                </a>
            </div>

            <!-- logo collapse icon -->

            <div class="sidebar-collapse">
                <a href="#" class="sidebar-collapse-icon with-animation">
                    <!-- add class "with-animation" if you want sidebar to have animation during expanding/collapsing transition -->
                    <i class="entypo-menu"></i>
                </a>
            </div>

            <!-- open/close menu icon (do not remove if you want to enable menu on mobile devices) -->
            <div class="sidebar-mobile-menu visible-xs">
                <a href="#" class="with-animation">
                    <!-- add class "with-animation" to support animation -->
                    <i class="entypo-menu"></i>
                </a>
            </div>

        </header>

        <ul id="main-menu" class="">
            <!-- add class "multiple-expanded" to allow multiple submenus to open -->
            <!-- class "auto-inherit-active-class" will automatically add "active" class for parent elements who are marked already with class "active" -->
            <!-- 搜索框 -->
            <li id="search">
                <form method="get" action="" enctype="multipart/form-data">
                    <input type="text" name="q" class="search-input" id="什么是" placeholder="请输入你想搜索的内容....">
                    <button type="submit">
                        <i class="entypo-search" id="submit"></i>
                    </button>
                </form>
            </li>

            <li>
                <a href="system-index.html">
                    <i class="entypo-home active"></i>
                    <span>首页</span>
                </a>
            </li>

            <li class="">
                <a href="">
                    <i class="entypo-database"></i>
                    <span>产品库</span>
                </a>
                <ul>
                    <li class="">
                        <a href="product-info.html">
                            <span>产品信息库</span>
                        </a>
                    </li>
                    <li>
                        <a href="function-info.html">
                            <span>功能信息库</span>
                        </a>
                    </li>
                    <li>
                        <a href="part-info.html">
                            <span>零件信息库</span>
                        </a>
                    </li>
                </ul>
            </li>
            <li class="">
                <a href="">
                    <i class="entypo-lamp"></i>
                    <span>计算方法</span>
                </a>
                <ul>
                    <li>
                        <a href="calculate-method.html">
                            <span>方法库</span>
                        </a>
                    </li>
                </ul>
            </li>
            <li class="">
                <a href="">
                    <i class="entypo-rocket"></i>
                    <span>计算</span>
                </a>
                <ul>
                    <li class="">
                        <a href="product-cal.html">
                            <span>产品计算</span>
                        </a>
                    </li>
                </ul>
            </li>
            <li class="">
                <a href="">
                    <i class="entypo-chart-bar"></i>
                    <span>结果展示</span>
                </a>
                <ul>
                    <li class="">
                        <a href="product-result.html">
                            <span>产品结果</span>
                        </a>
                    </li>
                </ul>
            </li>
            <li class="opened">
                <a href="">
                    <i class="entypo-layout"></i>
                    <span>背景数据管理</span>
                </a>
                <ul>
                    <li class="active">
                        <a href="manufacture-info.html">
                            <span>工艺数据管理</span>
                        </a>
                    </li>
                    <li>
                        <a href="transport-info.html">
                            <span>运输数据管理</span>
                        </a>
                    </li>
                    <li>
                        <a href="material-info.html">
                            <span>材料数据管理</span>
                        </a>
                    </li>
                </ul>
            </li>
            <li>
                <a href="about-us.html">
                    <i class="entypo-info-circled"></i>
                    <span>关于我们</span>
                </a>
            </li>

        </ul>

    </div>
    <div class="main-content">

        <div class="row">

            <!-- Profile Info and Notifications -->
            <div class="col-md-6 col-sm-8 clearfix">

                <ul class="user-info pull-left pull-none-xsm">
                    <!-- 个人简介 -->
                    <li class="profile-info dropdown">
                        <!-- add class "pull-right" if you want to place this from right -->
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown">

                            <img src="static/picture/head1.png" alt="" class="img-circle" width="44">
                            <a id="username"></a>
                        </a>
                    </li>
                </ul>

            </div>

            <!-- 退出按钮 -->
            <div class="col-md-6 col-sm-4 clearfix hidden-xs">
                <ul class="list-inline links-list pull-right">
                    <li>
                        <a href="index.html" >
                            <strong>Log Out</strong> <i class="entypo-logout  right"></i>
                        </a>
                    </li>
                    <li class="sep"></li>
                </ul>


                <ul class="list-inline links-list pull-right" >
                    <li>
                        <a href="play/Excel表模板.zip" >
                            <strong>Download</strong> <i class="entypo-attach left" ></i>
                        </a>
                    </li>
                    <li class="sep"></li>
                </ul>

                <ul class="list-inline links-list pull-right" >
                    <li>
                        <a data-toggle="modal" data-target="#bomtips">
                            <strong>Bom Tips </strong><i class="entypo-github left"  ></i>
                        </a>
                    </li>
                    <li class="sep"></li>
                </ul>

            </div>

        </div>
        <hr>
        <ol class="breadcrumb bc-3">
            <li>
                <a href="system-index.html"><i class="entypo-home"></i>首页</a>
            </li>
            <li>
                <a >背景数据管理</a>
            </li>
            <li class="active">
                <strong>工艺数据管理</strong>
            </li>
        </ol>
        <!--<center>
            <h3>工艺数据管理</h3>
        </center>-->

        <table class="table table-bordered datatable" id="table-1">
            <thead>
            <tr>
                <th>ID</th>
                <th>材料名称</th>
                <th>材料类型(s)</th>
                <th>单位</th>
                <th>地区</th>
                <th>来源</th>
                <th>备注</th>
                <th>单位</th>
                <th>地区</th>
                <th>来源</th>
                <th width="200px">备注</th>
                <th width="300px">操作</th>
            </tr>
            </thead>
            <tbody id="mat" class="mat">

            </tbody>
        </table>
        <a class="btn btn-primary" data-toggle="modal" data-target="#myModal">
            <i class="entypo-plus"></i> 单条添加
        </a>
        <a class="btn btn-primary" data-toggle="modal" data-target="#myModal1">
            <i class="entypo-plus"></i> 批量添加
        </a>
        <script type="text/javascript">
            var operat_id;//要操作的id
            var detailVO;
            var responsiveHelper;
            var breakpointDefinition = {
                tablet: 1024,
                phone: 480
            };
            var userinfo;  //用户信息
            var tableContainer;
            var material;   //材料集合
            jQuery(document).ready(function ($) {
                var token = window.localStorage["token"];
                if (token == null || token == "") {
                    alert("没有登录，不能下单");
                    window.location.href = "login.html";
                    return false;
                }
                $.ajax({
                    type: "POST",
                    url: "http://" + g_host + "/user/getuserinfo",
                    xhrFields: {withCredentials: true},
                    data: {
                        "token": token
                    },
                    success: function (data) {
                        if (data.status == "success") {
                            userinfo = data.data;
                            $("#username").text(userinfo.username);
                            $.ajax({
                                type: "GET",
                                url: "http://" + g_host + "/manufacture/get?id="+userinfo.id,
                                xhrFields: {withCredentials: true},
                                success: function (data) {
                                    if (data.status == "success") {
                                        material = data.data;
                                        reloadDom();
                                    } else {
                                        alert("获取材料信息失败，原因为" + data.data.errMsg);
                                    }
                                },
                                error: function (data) {
                                    alert("获取材料信息失败，原因为服务器内部错误");
                                }
                            });
                        } else {
                            alert("登录信息过期！请重新登录！");
                            window.location.href = "login.html";
                        }
                    },
                    error: function (data) {
                        alert("登录失败，原因为服务器内部错误");
                        window.location.href = "login.html";
                    }
                });

                tableContainer = $("#table-1");
                //表格设置
                tableContainer.dataTable({
                    "sPaginationType": "bootstrap",
                    "iDisplayLength": 10000,
                    "aLengthMenu": [[-1, 12, 20, 40, 80], ["All", 12, 20, 40, 80]],
                    "bStateSave": true,
                    "bInfo": true,
                    "aoColumns": [
                        {"sTitle": "ID"},
                        {"sTitle": "工艺名称"},
                        {"sTitle": "工艺类型"},
                        {"sTitle": "机床型号"},
                        {"sTitle": "机床功率"},
                        {"sTitle": "加工材料"},
                        {"sTitle": "单位"},
                        {"sTitle": "材料去除率（%）"},
                        {"sTitle": "数据来源"},
                        {"sTitle": "备注"},
                        {"sTitle": "操作"},
                        {"sTitle": "id", "bVisible": false}
                    ],

                    // Responsive Settings
                    bAutoWidth: false,
                    //页面加载的初始化方法
                    fnPreDrawCallback: function () {
                        // Initialize the responsive datatables helper once.
                        if (!responsiveHelper) {
                            responsiveHelper = new ResponsiveDatatablesHelper(tableContainer, breakpointDefinition);
                        }
                    },
                    fnRowCallback: function (nRow, aData, iDisplayIndex, iDisplayIndexFull) {
                        responsiveHelper.createExpandIcon(nRow);

                    },
                    fnDrawCallback: function (oSettings) {
                        responsiveHelper.respond();
                    }
                });

                $(".dataTables_wrapper select").select2({
                    minimumResultsForSearch: -1
                });
            });

            function reloadDom() {

                for (var i = 0; i < material.length; i++) {
                    var dom = [(i + 1), material[i].name, material[i].type, material[i].machineTool, material[i].power,
                        material[i].material, material[i].unit, material[i].percent, material[i].origin,
                        material[i].comments,
                        "<td>\n" +
                        "\t\t\t\t<a href=\"#\" class=\"btn btn-info btn-sm btn-icon icon-left\"  id=\"" + material[i].id + "\"  data-toggle=\"modal\" data-target=\"#material_detail\">\n" +
                        "\t\t\t\t\t<i class=\"entypo-info\"></i>\n" +
                        "\t\t\t\t\t详情\n" +
                        "\t\t\t\t</a>\n" +
                        "\t\t\t\t<a href=\"#\" class=\"btn btn-danger btn-sm btn-icon icon-left\"  id=\"q" + material[i].id + "\" >\n" +
                        "\t\t\t\t\t<i class=\"entypo-cancel\"></i>\n" +
                        "\t\t\t\t\t删除\n" +
                        "\t\t\t\t</a>\n" +
                        "\t\t\t</td>"
                        , material[i].id];
                    $('#table-1').dataTable().fnAddData(dom);


                    //查看材料详情
                    $("#" + material[i].id).on("click", function (e) {
                        operat_id = this.id;
                        console.log(operat_id);

                        $.ajax({
                            type: "GET",
                            contentType: "application/x-www-form-urlencoded",
                            url: "http://" + g_host + "/manufacture/getdetail?id=" + operat_id,
                            xhrFields: {withCredentials: true},
                            success: function (data) {
                                if (data.status == "success") {
                                    detailVO = data.data;
                                    console.log(data.data);
                                    reloadDetail(detailVO);
                                } else {
                                    alert("查看详情失败，原因为" + data.data.errMsg);
                                    window.location.href = "manufacture-info.html";
                                }
                            },
                            error: function (data) {
                                alert("查看详情失败，原因为" + data.responseText);
                                window.location.href = "manufacture-info.html";
                            }
                        });

                    });
                    //删除材料
                    $("#q" + material[i].id).on("click", function (e) {
                        operat_id = this.id;
                        operat_id = operat_id.substring(1, operat_id.length);
                        $.ajax({
                            type: "GET",
                            contentType: "application/x-www-form-urlencoded",
                            url: "http://" + g_host + "/manufacture/deletebyid?id=" + operat_id,
                            xhrFields: {withCredentials: true},
                            success: function (data) {
                                if (data.status == "success") {
                                    alert("删除成功！")
                                    window.location.href = "manufacture-info.html";
                                } else {
                                    alert("删除失败，原因为" + data.data.errMsg);
                                    window.location.href = "manufacture-info.html";

                                }
                            },
                            error: function (data) {
                                alert("删除失败，原因为" + data.responseText);
                                window.location.href = "manufacture-info.html";
                            }
                        });
                    });

                }

            }

            function reloadDetail(detailVO) {
                $("#VOcoal").val(detailVO.煤);
                $("#VOoil").val(detailVO.石油);
                $("#VOgas").val(detailVO.天然气);
                $("#VOco").val(detailVO.co);
                $("#VOco2").val(detailVO.co2);
                $("#VOso2").val(detailVO.so2);
                $("#VOnox").val(detailVO.nox);
                $("#VOch4").val(detailVO.ch4);
                $("#VOh2s").val(detailVO.h2s);
                $("#VOhcl").val(detailVO.hcl);
                $("#VOcod").val(detailVO.cod);
                $("#VOnh3").val(detailVO.nh3);
                $("#VOcfc11").val(detailVO.cfc11);
                $("#VOcfc12").val(detailVO.cfc12);
                $("#VOcfc113").val(detailVO.cfc113);
            }


        </script>


    </div>

</div>

<!--查看数据详情的模态窗口-->
<div class="modal fade" id="material_detail" role="dialog">
    <div class="modal-dialog" style="width:550px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span>×</span>
                </button>
                <center>
                    <h3 class="modal-title">
                        材料详情
                    </h3>
                </center>
            </div>
            <div class="modal-body" style="height: 500px;">
                <div style="width:150px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">煤</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="coal"
                                   id="VOcoal"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">石油</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="oil"
                                   id="VOoil"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">天然气</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="gas"
                                   id="VOgas"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">一氧化碳</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="co" id="VOco"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">二氧化碳</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="co2"
                                   id="VOco2"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">二氧化硫</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="so2"
                                   id="VOso2"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">氮氧化合物（NOx）</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="nox"
                                   id="VOnox"/>
                        </div>
                    </div>
                    </p>
                </div>

                <div style="width:150px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">CH4</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="ch4"
                                   id="VOch4"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">H2S</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="h2s"
                                   id="VOh2s"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">HCL</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="hcl"
                                   id="VOhcl"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">COD</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="cod"
                                   id="VOcod"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">NH3</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="nh3"
                                   id="VOnh3"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">CFC-11</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="cfc11"
                                   id="VOcfc11"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">CFC-12</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="cfc12"
                                   id="VOcfc12"/>
                        </div>
                    </div>
                    </p>
                </div>
                <div style="width:150px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">CFC-113</label>
                        <div>
                            <input class="form-control" type="text" readonly="true" placeholder="" name="cfc113"
                                   id="VOcfc113"/>
                        </div>
                    </div>
                    </p>
                </div>
            </div>
            <br>
        </div>
    </div>
</div>


<!--添加材料的模态窗口-->
<div class="modal fade" id="myModal" role="dialog">
    <div class="modal-dialog" style="width:1020px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span>×</span>
                </button>
                <center>
                    <h3 class="modal-title" id="myModalLabel">
                        添加新工艺方式
                    </h3>
                </center>
            </div>
            <div class="modal-body" style="height: 480px;">
                <div style="width:250px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">工艺名称</label>
                        <div>
                            <input class="form-control" type="text" placeholder="工艺名称" name="mat_name" id="man_name"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">工艺类型</label>
                        <div>
                            <input class="form-control" type="text" placeholder="粗/精/半精加工" name="mat_type" id="man_type"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">机床型号</label>
                        <div>
                            <input class="form-control" type="text" placeholder="CA-6140" name="mat_type" id="man_tool"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">机床功率</label>
                        <div>
                            <input class="form-control" type="text" placeholder="3000W" name="mat_type" id="man_power"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">加工材料</label>
                        <div>
                            <input class="form-control" type="text" placeholder="加工材料" name="mat_type" id="man_material"/>
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="control-label">单位</label>
                        <div>
                            <input class="form-control" type="text" placeholder="kwh/kg" name="mat_unit" id="man_unit"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">材料去除率</label>
                        <div>
                            <input class="form-control" type="text" placeholder="去除百分比" name="mat_type" id="man_percent"/>
                        </div>
                    </div>

                    </p>
                </div>

                <div style="width:250px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">数据来源</label>
                        <div>
                            <input class="form-control" type="text" placeholder="用户输入/E-balance/Gabi" name="mat_type" id="man_origin"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">备注</label>
                        <textarea class="form-control" type="text" placeholder="备注" name="mat_comments"
                                  id="man_comments" style="height:100px"></textarea>
                    </div>
                    </p>
                </div>


                <div style="width:150px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">

                    <div class="form-group">
                        <label class="control-label">煤</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="coal" id="coal"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">石油</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="oil"
                                   id="oil"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">天然气</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="gas"
                                   id="gas"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">一氧化碳</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="co"
                                   id="co"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">二氧化碳</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="co2"
                                   id="co2"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">二氧化硫</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="so2"
                                   id="so2"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">氮氧化合物（NOx）</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="nox"
                                   id="nox"/>
                        </div>
                    </div>
                    </p>
                </div>

                <div style="width:150px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">CH4</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="ch4" id="ch4"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">H2S</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="h2s"
                                   id="h2s"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">HCL</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="hcl"
                                   id="hcl"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">COD</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="cod"
                                   id="cod"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">NH3</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="nh3"
                                   id="nh3"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">CFC-11</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="cfc11"
                                   id="cfc11"/>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="control-label">CFC-12</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="cfc12"
                                   id="cfc12"/>
                        </div>
                    </div>
                    </p>
                </div>
                <div style="width:150px;float:left;padding-left: 20px;padding-right: 20px">
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">CFC-113</label>
                        <div>
                            <input class="form-control" type="text" placeholder="" name="cfc113" id="cfc113"/>
                        </div>
                    </div>
                    </p>
                </div>
            </div>
            <br>
            <div class="modal-footer">
                <p align="center">
                    <button type="button" class="btn btn-default" id="material_submit">
                        提交
                    </button>
                </p>
            </div>
        </div>
    </div>
</div>


<div class="modal fade" id="myModal1" role="dialog">
    <div class="modal-dialog" style="width:300px">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span>×</span>
                </button>
                <center>
                    <h3 class="modal-title" id="">
                        批量添加材料
                    </h3>
                </center>
            </div>
            <div class="modal-body" style="height: 200px;">
                <div>
                    <p align="center">
                    <div class="form-group">
                        <label class="control-label">选取工艺的BOM表</label>
                        <form id="upload" name="form" action="" enctype="multipart/form-data" method="post" target="frameName" style="padding-top: 10px">
                            <input name="userVOIdFile" type="hidden"  id="userVOIdFile" style="width:150px;float:left;padding-left: 0px;padding-right: 10px">
                            <input name="uploadfile" type="file" accept=".xlsx,.xls" id="upload_file"
                                   style="width:150px;float:left;padding-left: 0px;padding-right: 10px">
                            <button type="submit" style="width:55px;float:right;padding-left: 2px" id="save">提交</button>
                        </form>
                        <iframe src="" frameborder="0" name="frameName" style="width: 0px;height: 0px"></iframe>
                    </div>
                    </p>
                </div>
            </div>
        </div>
    </div>
</div>

<script>
    jQuery(document).ready(function () {

        $("#save").on("click", function () {
            $("#userVOIdFile").val(userinfo.id);
            document.form.action = "http://"+g_host+"/manufacture/submitfile";
            alert("BOM上传成功!");
            window.location.href = "manufacture-info.html";
        })


        //绑定otp的click时间用于向后端发送获取手机验证码的请求
        $("#material_submit").on("click", function () {
            var man_name = $("#man_name").val();
            var man_type = $("#man_type").val();
            var man_tool = $("#man_tool").val();
            var man_power = $("#man_power").val();
            var man_material = $("#man_material").val();
            var man_unit = $("#man_unit").val();
            var man_percent = $("#man_percent").val();
            var man_origin = $("#man_origin").val();
            var man_comments = $("#man_comments").val();


            var coal = $("#coal").val();
            var oil = $("#oil").val();
            var gas = $("#gas").val();
            var co = $("#co").val();
            var co2 = $("#co2").val();
            var so2 = $("#so2").val();
            var nox = $("#nox").val();
            var ch4 = $("#ch4").val();
            var h2s = $("#h2s").val();
            var hcl = $("#hcl").val();
            var cod = $("#cod").val();
            var nh3 = $("#nh3").val();
            var cfc11 = $("#cfc11").val();
            var cfc12 = $("#cfc12").val();
            var cfc113 = $("#cfc113").val();
            function isRealNum(val){
                if(val === "" || val ==null){
                    return true;
                }else{
                    return isNaN(val);
                }
            }

            function isNoBlank(val) {
                if(val === "" || val ==null){
                    return true;
                }else{
                    return false;
                }
            }

            if(isNoBlank(man_name)){
                alert("工艺名字不能为空！");
                return false;
            }
            if(isNoBlank(man_type)){
                alert("工艺类型不能为空！");
                return false;
            }
            if(isNoBlank(man_material)){
                alert("加工材料不能为空！");
                return false;
            }
            if(isRealNum(man_percent)){
                alert("材料去除率不能为空！");
                return false;
            }
            if(isNoBlank(man_unit)){
                alert("单位不能为空！");
                return false;
            }
            if(isNoBlank(man_origin)){
                alert("数据来源不能为空！");
                return false;
            }


            if (isRealNum(coal)) {
                alert("煤炭信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(oil)) {
                alert("原油信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(gas)) {
                alert("天燃气信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(co)) {
                alert("一氧化碳信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(co2)) {
                alert("二氧化碳信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(so2)) {
                alert("二氧化硫信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(nox)) {
                alert("nox信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(ch4)) {
                alert("ch4信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(h2s)) {
                alert("h2s信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(hcl)) {
                alert("hcl信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(cod)) {
                alert("cod信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(nh3)) {
                alert("nh3信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(cfc11)) {
                alert("cfc11信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(cfc12)) {
                alert("cfc12信息不能为空！且为数字");
                return false;
            }
            if (isRealNum(cfc113)) {
                alert("cfc113信息不能为空！且为数字");
                return false;
            }


            $.ajax({
                type: "POST",
                contentType: "application/x-www-form-urlencoded",
                url: "http://" + g_host + "/manufacture/submit",
                data: {
                    "man_name": man_name,
                    "man_type": man_type,
                    "man_tool": man_tool,
                    "man_power": man_power,
                    "man_material": man_material,
                    "man_unit": man_unit,
                    "man_percent": man_percent,
                    "man_origin": man_origin,
                    "man_comments": man_comments,

                    "coal": coal,
                    "oil": oil,
                    "gas": gas,
                    "co": co,
                    "co2": co2,
                    "so2": so2,
                    "nox": nox,
                    "ch4": ch4,
                    "h2s": h2s,
                    "hcl": hcl,
                    "cod": cod,
                    "nh3": nh3,
                    "cfc11": cfc11,
                    "cfc12": cfc12,
                    "cfc113": cfc113,
                    "user_id":userinfo.id
                },
                xhrFields: {
                    withCredentials: true
                }
                ,
                success: function (data) {
                    if (data.status == "success") {
                        alert("添加成功");
                        reloadDom();
                        window.location.href = "manufacture-info.html";
                    } else {
                        alert("添加失败，原因为" + data.data.errMsg);
                    }
                }
                ,
                error: function (data) {
                    alert("添加失败，原因为" + data.responseText);
                }
            })
            ;
            return false;
        });


    });
</script>
<div class=" modal fade" id="bomtips" role="dialog">
    <div class="modal-dialog" style="width:40%">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal">
                    <span>×</span>
                </button>
                <center>
                    <h4 class="modal-title">
                        Bom填写小提示
                    </h4>
                </center>
            </div>

            <div style="padding-left: 20px;padding-right: 20px">

                <ul class="nav nav-tabs bordered "><!-- available classes "bordered", "right-aligned" -->
                    <li class="active">
                        <a href="#g1" data-toggle="tab">
                            <span class="visible-xs"><i class="entypo-home"></i></span>
                            <span class="hidden-xs">产品Bom</span>
                        </a>
                    </li>
                    <li>
                        <a href="#g2" data-toggle="tab">
                            <span class="visible-xs"><i class="entypo-mail"></i></span>
                            <span class="hidden-xs">工艺Bom</span>
                        </a>
                    </li>
                    <li>
                        <a href="#g3" data-toggle="tab">
                            <span class="visible-xs"><i class="entypo-mail"></i></span>
                            <span class="hidden-xs">运输Bom</span>
                        </a>
                    </li>
                    <li>
                        <a href="#g4" data-toggle="tab">
                            <span class="visible-xs"><i class="entypo-user"></i></span>
                            <span class="hidden-xs">材料Bom</span>
                        </a>
                    </li>
                </ul>

                <div class="tab-content">
                    <div class="tab-pane active" id="g1">
                        <div class="modal-body" style="height: 550px;">
                            <p><strong>产品Bom</strong>一共包含16列，分别为 序号、代号、名称、型号、功能、参数、每台数量、材料、单重(kg)、总重(kg)、备注、产地、运输距离（km）、运输方式、工艺方式、回收（百分比）。</p>
                            <p><strong>1、</strong> *序号：产品序号需要按照目录结构一样进行编写，1、1.1、1.2、2、2.1、2.2... （序号直接必须有层级关系，必须父级存在的时候才能编写子序号，否则无法进行计算！）</p>
                            <p><strong>2、</strong> 代号：代号表示企业内部对零部件的编号，可以不写！</p>
                            <p><strong>3、</strong> *名称：代表该零件的名字，必须填写，否则无法计算！</p>
                            <p><strong>4、</strong> 型号：为该零部件的零件型号，请如实填写，当其他数据缺失时，此型号信息将作为智能填补的重要依据！</p>
                            <p><strong>5、</strong> 功能：该零部件的主要作用,尽量填写，该信息将作为智能填补的依据！</p>
                            <p><strong>6、</strong> 参数：该零部件的其他参数，可以不写！</p>
                            <p><strong>7、</strong> *每台数量：每台产品所包含该零部件的数量</p>
                            <p><strong>8、</strong> *材料：该零部件的主要材料，如果是装配体，就写装配体！叶子节点的零件必须填写材料（材料信息不可缺失，如不知道请填写 null 后台会自动补全）</p>
                            <p><strong>9、</strong> *单重(kg)：一个零部件的重量，单位kg</p>
                            <p><strong>10、</strong> *总重(kg)：一台产品中该零部件的总重（该数据不可缺失！如不清楚请填写0，后台会智能补全）</p>
                            <p><strong>11、</strong> 备注：零部件的备注，可以为空，如过数据经过后台智能补全，补全信息会出现在这一栏里！</p>
                            <p><strong>12、</strong> 产地：零部件的产地</p>
                            <p><strong>13、</strong> *运输距离（km）：零部件的运输距离，必须填写！如不知道请填写0，后台会自动补全！</p>
                            <p><strong>14、</strong> *运输方式：运输方式必须填写，先查看背景运输数据填写，如不知道，请填写null后台会自动补全！</p>
                            <p><strong>15、</strong> *工艺方式：零部件的加工工工艺，先查看背景工艺数据再填写（多个工艺请用-分开，比如 切削粗加工共-切削半精加工共-切削精加工），该数据不能缺失！如不清楚请填写null后台会自动补全！如果物料没有制造阶段，请填写不计算，后台会自动跳过制造阶段！</p>
                            <p><strong>16、</strong> *回收：填写回收的百分比，（整数），该数据不可缺失！，如不清楚请填写0，后台会自动补全！</p>
                            <p><strong>注：</strong>*号为必填内容，如果不清楚请填写null（非数值型数据）和0（数值型数据）</p>
                        </div>
                    </div>
                    <div class="tab-pane" id="g2">
                        <div class="modal-body" style="height: 550px;">
                            <p><strong>工艺Bom</strong>一共包含24列，分别为工艺名称、工艺类型、机床型号、机床功率、加工材料、单位、材料去除率、数据来源、备注、煤、石油、天然气、co、co2、so2、nox、ch4、h2s、hcl、cod、nh3、cfc11、cfc12、cfc113

                            </p>

                            <p><strong>1、</strong> *工艺名称：表示该工艺的名字，需要加上加工工类型，该信息为后台计算匹配的唯二信息，不可缺失！</p>
                            <p><strong>2、</strong> *工艺类型：表示该工艺类型（比如：粗加工、半精加工、精加工...）</p>
                            <p><strong>3、</strong> 机床型号：表示加工零部件的机床代号</p>
                            <p><strong>4、</strong> 机床功率：实际功率</p>
                            <p><strong>5、</strong> *加工材料：该工艺所加工的材料,该信息作为后台计算匹配的唯二信息，不可缺失！</p>
                            <p><strong>6、</strong> 单位：kg （加工1kg该材料所产生的环境排放）</p>
                            <p><strong>7、</strong> *材料去除率：该信息不可缺失！,Double类型的数据，请如实填写</p>
                            <p><strong>8、</strong> 数据来源：填写你的数据来源</p>
                            <p><strong>9、</strong> 备注：用户备注</p>
                            <p><strong>10、</strong> *其他：环境排放的数值，小数位数最多支持20位,这些列的信息不可缺失！</p>
                            <p><strong>注：</strong>*号为必填内容，如果缺失将无法计算！</p>
                            <p><strong>注：</strong>该bom的数据单位为比能耗，即加工1kg物质所产生的电能，单位为kwh/cm3,需要用户将其转化为电能,然后和1kwh的电能所产生的环境排放进行等比例扩大或缩小！ </p>
                            <p><strong>比能耗转化为电能计算公式：</strong> 比能耗（kwh/cm3） × 10^6 ÷ 材料密度（kg/m3）= 我们的单位（kwh/kg）</p>

                        </div>
                    </div>
                    <div class="tab-pane" id="g3">
                        <div class="modal-body" style="height: 550px;">
                            <p><strong>运输Bom</strong>一共包含22列，分别为运输名称、运输工具、单位、地区、数据来源 、运输类型（陆运、水运）
                                、备注、煤、石油、天然气、co、co2、so2、nox、ch4、h2s、hcl、cod、nh3、cfc11、cfc12、cfc113
                            </p>

                            <p><strong>1、</strong> *运输名称：表示该运输的名字，该信息为后台计算匹配的唯一信息，不可缺失！</p>
                            <p><strong>2、</strong> 运输工具：表示该运输所使用的工具信息</p>
                            <p><strong>3、</strong> 单位：kg/km</p>
                            <p><strong>4、</strong> 地区：表示该运输数据来自哪个地区</p>
                            <p><strong>5、</strong> 数据来源：该信息你是从哪里搜集到的，请如实填写！</p>
                            <p><strong>6、</strong> 运输类型：陆运、水运、空运...</p>
                            <p><strong>7、</strong> 备注：用户备注</p>
                            <p><strong>8、</strong> *其他：环境排放的数值，小数位数最多支持20位,这些列的信息不可缺失！</p>
                            <p><strong>注：</strong>*号为必填内容，如果缺失将无法计算！</p>
                            <p><strong>注：</strong>此表中所有数据单位均为kg/km 无法变更，需要您自行转换输入！</p>

                        </div>
                    </div>
                    <div class="tab-pane" id="g4">
                        <div class="modal-body" style="height: 550px;">
                            <p><strong>材料Bom</strong>一共包含20列，分别为材料名称、类型（物质、能量、排放）、单位、地区、数据来源、备注
                                、煤、石油、天然气、co、co2、so2、nox、ch4、h2s、hcl、cod、nh3、cfc11、cfc12、cfc113
                            </p>

                            <p><strong>1、</strong> *材料名称：表示该运输的名字，该信息为后台计算匹配的唯一信息，不可缺失！</p>
                            <p><strong>2、</strong> 类型：该物质的类型（物质、能量、排放...）</p>
                            <p><strong>3、</strong> 单位：kg 固定不变 需要用户自行换算</p>
                            <p><strong>4、</strong> 地区：表示该物质数据来自哪个地区</p>
                            <p><strong>5、</strong> 数据来源：该信息你是从哪里搜集到的，请如实填写！</p>
                            <p><strong>7、</strong> 备注：用户备注</p>
                            <p><strong>8、</strong> *其他：环境排放的数值，小数位数最多支持20位,这些列的信息不可缺失！</p>
                            <p><strong>注：</strong>*号为必填内容，如果缺失将无法计算！</p>
                            <p><strong>注：</strong>此表中所有数据单位均为kg 无法变更，需要您自行转换输入！</p>
                        </div>
                    </div>
                </div>


            </div>

        </div>
    </div>
</div>
<link rel="stylesheet" href="static/css/datatables.responsive.css">
<link rel="stylesheet" href="static/css/select2-bootstrap.css">
<link rel="stylesheet" href="static/css/select2.css">
<link rel="stylesheet" href="static/css/jquery-jvectormap-1.2.2.css">
<link rel="stylesheet" href="static/css/rickshaw.min.css">
<link rel="stylesheet" href="static/my.css">
<!-- Bottom Scripts -->
<script src="static/js/main-gsap.js"></script>
<script src="static/js/jquery-ui-1.10.3.minimal.min.js"></script>
<script src="static/js/bootstrap.js"></script>
<script src="static/js/joinable.js"></script>
<script src="static/js/resizeable.js"></script>
<script src="static/js/neon-api.js"></script>
<script src="static/js/jquery.dataTables.min.js"></script>
<script src="static/js/TableTools.min.js"></script>
<script src="static/js/dataTables.bootstrap.js"></script>
<script src="static/js/jquery.dataTables.columnFilter.js"></script>
<script src="static/js/lodash.min.js"></script>
<script src="static/js/datatables.responsive.js"></script>
<script src="static/js/select2.min.js"></script>
<script src="static/js/neon-chat.js"></script>
<script src="static/js/neon-custom.js"></script>
<script src="static/js/neon-demo.js"></script>

<!-- Bottom Scripts -->
<script src="static/js/jquery-jvectormap-1.2.2.min.js"></script>
<script src="static/js/jquery.sparkline.min.js"></script>
<script src="static/js/d3.v3.js"></script>
<script src="static/js/rickshaw.min.js"></script>
<script src="static/js/raphael-min.js"></script>
<script src="static/js/morris.min.js"></script>
<script src="static/js/toastr.js"></script>

</body>

</html>